package com.example.arithmeticleetcode.leetcode.July;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-07-22 10:03
 **/
public class Demo08 {

    private String str = "11";

    public static void main(String[] args) {
        Demo08 demo08 = new Demo08();
        System.out.println(demo08.str);
        demo08.test();
        System.out.println(demo08.str);
        demo08.test2();
        System.out.println(demo08.str);

        System.out.println("=====================================");

        System.out.println(numWaterBottles(9, 3));
        System.out.println(numWaterBottles(15, 4));
        System.out.println(numWaterBottles(5, 5));
        System.out.println(numWaterBottles(2, 3));

    }

    public static int numWaterBottles(int numBottles, int numExchange) {
        //总共喝几瓶酒
        int result = numBottles;
        //每次喝多少
        int perDrink = numBottles;
        while (perDrink / numExchange > 0) {
            result += perDrink / numExchange;
            perDrink = perDrink / numExchange + perDrink % numExchange;
        }
        return result;
    }

    public void test() {
        str = "222";
    }

    public void test2() {
        str = "33";
    }
}
